package com.tourism.controller;

import com.github.pagehelper.PageInfo;
import com.tourism.entity.Hotel;
import com.tourism.entity.HotelQuery;
import com.tourism.entity.Line;
import com.tourism.service.HotelService;
import com.tourism.util.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 酒店相关的控制器
 * @Author z
 * @Date 2021-03-01 20:40
 */
@Controller
@RequestMapping("/hotel")
public class HotelController {


    @Autowired
    private HotelService hotelService;

    /**
     * 根据酒店id查询酒店信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getHotelById")
    @ResponseBody
    public Hotel getHotelById(Long id) {
        return hotelService.getHotelById(id);
    }
    /**
     * 根据景点id删除酒店信息
     *
     * @param id
     * @return
     */
    @DeleteMapping("/deleteHotelById")
    @ResponseBody
    public Response deleteHotelById(Long id) {
        return Response.success(hotelService.deleteHotelById(id));
    }

    /**
     * 新增酒店
     *
     * @param hotel
     * @return
     */
    @PostMapping("/addHotel")
    @ResponseBody
    public Response addHotel(@RequestBody Hotel hotel) {

        return Response.success(hotelService.addHotel(hotel));

    }
    /**
     * 修改酒店
     *
     * @param hotel
     * @return
     */
    @PostMapping("/updateHotel")
    @ResponseBody
    public Response updateHotel(@RequestBody Hotel hotel) {
        return Response.success(hotelService.updateHotel(hotel));

    }


    /**
     * 查询酒店列表
     *
     * @param hotelQuery
     * @return
     */
    @PostMapping("/getHotelList")
    @ResponseBody
    public PageInfo<Hotel> getHotelList(@RequestBody HotelQuery hotelQuery) {
        return hotelService.getHotelList(hotelQuery);
    }

}
